<?php

namespace App;

use App\Http\Services\FileManager;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\MedicineBanner
 *
 * @property int $id
 * @property int $img_id banner图图片id
 * @property int $merchant_medicine_id 药品id
 * @property int $sort 排序 数值越小越靠前
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\MedicineBanner onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner whereImgId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner whereMerchantMedicineId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner whereSort($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\MedicineBanner whereUpdatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\MedicineBanner withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\MedicineBanner withoutTrashed()
 * @mixin \Eloquent
 */
class MedicineBanner extends Model
{
    protected $table = 'medicine_banner';
    use SoftDeletes;

    public static function getMedicineBanner($merchant_id){
        $data=self::whereMerchantMedicineId($merchant_id)->get();
        if (count($data) > 0){
            foreach ($data as $item){
                $item->img_url=FileManager::getImgUrl($item->img_id);
            }
        }

        return $data;
    }
}
